package com.ttx.pattern.example.command.after;

import com.ttx.pattern.example.command.after.command.DrawCircleCommand;
import com.ttx.pattern.example.command.after.command.DrawRectangleCommand;
import com.ttx.pattern.example.command.after.command.EraseCommand;
import com.ttx.pattern.example.command.after.invoker.DrawingBoard;
import com.ttx.pattern.example.command.after.receiver.Brush;
import com.ttx.pattern.example.command.after.receiver.Eraser;
import com.ttx.pattern.example.command.after.receiver.Pen;

/**
 * @author TimFruit
 * @date 19-5-5 下午10:57
 */
public class Client {
    public static void main(String[] args) {
        int buttonSize=7;
        DrawingBoard drawingBoard=new DrawingBoard(buttonSize);


        DrawCircleCommand penDrawCircleCmd=new DrawCircleCommand(new Pen());
        drawingBoard.setCommand(0, penDrawCircleCmd);

        DrawRectangleCommand brushDrawRectangleCmd=new DrawRectangleCommand(new Brush());
        drawingBoard.setCommand(1, brushDrawRectangleCmd);

        EraseCommand eraseCommand=new EraseCommand(new Eraser());
        drawingBoard.setCommand(2, eraseCommand);

        // 如果有其他receiver,可以添加对应command类,然后在这里的drawingBoard添加设置对应的command
        // 如此实现了命令接受者和命令调用这的解耦
        // 命令接受者的变化并不会使得命令调用者修改对应的代码



        // 调用命令
        drawingBoard.invokeCommand(0);
        drawingBoard.invokeCommand(1);
        drawingBoard.invokeCommand(2);


    }
}
